const mongoose = require('mongoose')

const dataPointSchema = new mongoose.Schema({
  clientid: { type: String, required: true },
  temperature: { type: Number, required: true },
  time: { type: Number, required: true },
  qos: { type: Number, required: true },
  topic: { type: String, required: true }
})
const temperatureSchema = new mongoose.Schema(
  {
    clientid: { type: String, required: true },
    hour: { type: Number, required: true },
    points: [dataPointSchema]
  },
  {
    timestamps: true // 开启自动生成时间戳
  }
)

module.exports = mongoose.model('Temperature', temperatureSchema)
